From adb7310d570457782d642dcd236e4aeb37579b22 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Tue, 2 Nov 2021 12:14:10 -0700 Subject: [PATCH 01/11] shave some bytes --- bin/sectorlisp.bin | Bin 512 -> 9536 bytes sectorlisp.S | 68 ++++++++++++++++++++------------------------- 2 files changed, 30 insertions(+), 38 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index cf9e79aa0e38f0cc821866f7668b6b922014dbab..94947da5a25679ae7ba8322004715d9aeffaec91 100755 GIT binary patch literal 9536 zcmeI2dvp}l9ml^n7!WiM6h$n`DuSS}CJ03^XhO1LG$bJj579Dil1;L(kGMO#JX$Oo zEMO1;g{bviwG=1~7L+2&YU-oPL#+5JDprdNp*~7gL}h#L%jO@&t;Xr|`E^^h%N7XvY;K>esI1cF_1C)W85!L!h`TO#03{+FtM0hPiL(K> z)OVw^I7OuOHG)!ssVy9d8M{%)2eKuknQ;q=2{S~boh;-$3L`JTX4%!XaJgoSyQcBAb<-B~S*n^fJy(oQuvB0<^(^+2X-+8XzFmMU0V zKC(w!r4w{K_CR~T(&7?SVcht#DhCS7N{diXRW=rd1r;bPl6zTcB^=}S4GQ0g%*@O_ zU3xy37GCh>f-T?YMi%YPjU8CIc~1V?eg__VvRm|YM2BFbK=d>by&kO@(L2!|-HiMN zhv&bZXA7sTToRp$rINnL8yHTXb7t_AjH(Sl+;_ zxtkE36)TT^5o_XBkEp5uAr!Ajot@&@bY=MBp$a-``Q zd3{6ge)F3f=ckLZ%+s7ecc-aIC)ZQD_{ z@hf9;Q}Z@)J|5@riI`9Hz=<9>#vW)i-){!=zqJ1`dN|SSIPL-U?kw;AQ15w)YgI9< z4nPquO5z+`NIe&W$U`ugd@1bYp}2%R3_0YVB9}ZIL&%q57OaxrcoUjvOi7EW?0 zYRP4&BbTFrJPuRI74VQN;U!nWM;?!x$P*ACPlQgMgfRI!%pgz3Eb{f3O}+uYB>xPz zkf-2QvJ*|@YTQPy#XPbLx0CCz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&5pRDewC)5y-JZwu$Gdh%wbDXdP_ycYuQ|8*eJV%pKCfOH*`=u z9h6y0Ny+p9rKH5OzC$ay(84VZnpW%aXqur|5xyO_v6TIWlAn~tcS=dQR(IJcJ*24m z#_XSS)F~yx%gqWYCv2{cn=5x_<%AA4)hUX+9XbQXT_Je{11UDj|6HZW-ST`_+{Vi5 ziMWlW{7EXQXVgBUB0H(aI(1U^=4Q4!!%&iY^?a!) z(TXRhL#t6zQ8`&Q>E@Dy~-Nde{lS!&-Ck$CORIJU&GgjUwMxh7ao792E}z*Q#RXOL@;?k!BDcbnaZ;Hk zYRq73I+Tqcz1f$kjZ;Qdj+z`)^&)sgoaW#hk)aCS@|!w$5);7a%;aG<1JsimYQ?Ij zM$3+p*S5xA%}-+nCQ>tFFuOH*a(MjCT30};^Em6x$(NjxY%Kkl17!J5Zf@3fbo<|j MBQaqTsh9!&2lPP`bN~PV delta 428 zcmWlU!Al!K6o=oey97g%MudRiAy5jHR+>mX7}k=D2&IQ0t=R@@{)HZ9wih*_>%lN8 zXlVB4sT7GKt5m2hn8l^EhZ|C3m3N`?sO423`znAg~F!#cyWH)*7o=uD#Hc<=F$s zRXgf5?eECKTNcSqNEV93O!e3KcGh6O3tNo^pIuo-rP=2P8^ooF@9pKiN^Wbxr)|6k z;=;Qlna0O436>KQdP6OFDJs0bsDn2oq8I^Je9HJo$&V3u7e7jvF}CML#Th=&NOOqJ zqb>7zF6$+cbR?mJU7Rt6ub^1U;~$l~OQ(g+`sT{171Yv3s=Ps1+~spxL0OOGT1nVW zIQjBEH_c(z!;QckWjdeG0`nG&UVbLP`rZ==IMw(AbDY-4{ Date: Wed, 3 Nov 2021 21:23:09 -0700 Subject: [PATCH 02/11] fix typo and avoid stack-race --- bin/sectorlisp.bin | Bin 9536 -> 512 bytes sectorlisp.S | 4 ++-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 94947da5a25679ae7ba8322004715d9aeffaec91..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I(1U^=4Q4!!%&iY^?a!) z(TXRhL#t6zQ8`&Q>E@Dy~-Nde{lS!&-Ck$CORIJU&GgjUwMxh7ao792E}z*Q#RXOL@;?k!BDcbnaZ;Hk zYRq73I+Tqcz1f$kjZ;Qdj+z`)^&)sgoaW#hk)aCS@|!w$5);7a%;aG<1JsimYQ?Ij zM$3+p*S5xA%}-+nCQ>tFFuOH*a(MjCT30};^Em6x$(NjxY%Kkl17!J5Zf@3fbo<|j MBQaqTsh9!&2lPP`bN~PV diff --git a/sectorlisp.S b/sectorlisp.S index 2b7eeb8..512ca26 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -51,9 +51,9 @@ _begin: push %cs # memory model cs=ds=es = 0x600 push %cs pop %ds pop %es - pop %ss mov $kSymbols,%si mov %si,%cx + pop %ss mov %cx,%sp cld xor %ax,%ax @@ -206,7 +206,7 @@ Cons: xchg %di,%ax xchg %di,%ax mov %fs,%di mov %ax,%fs - xchg %di,%ax +1: xchg %di,%ax ret Pairlis:cmp $NIL,%di # Pairlis(x:di,y:si,a:dx):ax From 3cb4b9743fe45a8ac02074cbaaa065907ca8a8bd Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 10:47:36 -0700 Subject: [PATCH 03/11] shave one more byte --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 3d0ec4dd9339b31e440308e18e82c05c5b8d3d16..6424579db4ae58e2962db272b81c05f3bd45774b 100755 GIT binary patch delta 60 zcmV-C0K@-)1b_sPF$TT@c8T#9kvARz5s_9f0dJPmcYunOz)=wkmo SDG!9a0O)&@2m$s3&Q+?RL>Mjr delta 60 zcmV-C0K@-)1b_sPF$NdD0(Ob Date: Fri, 5 Nov 2021 11:22:45 -0700 Subject: [PATCH 04/11] shave two more bytes --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 9 +++++---- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 6424579db4ae58e2962db272b81c05f3bd45774b..b032869bc20c8ea63a09bd819158c06c3a1d211a 100755 GIT binary patch delta 95 zcmV-l0HFVX1b_sPRT~ch=ve@;4d{&k>*&7#K#Bf{&^#b^0;-Ydcad-wB6GihKrq0u z|5v7U22ZYa`Rfo~z5qb-t~v#E>Q|&su66s7s#6MN|2!!VguDRgeUk?P_XN()RjT2u BE1LiS delta 95 zcmV-l0HFVX1b_sPRT~ij=vx4=4d{;m>*&7#K#Bf{&^#b^0;-Ydd694yBz3=lKrq0u z|5v7U2RcRnb@=NMUcLZ8@~%1sb?H~Es)WFG`jMzp3S$2}DG!9a0O)&@1p)U0RjTmU BD|!F` diff --git a/sectorlisp.S b/sectorlisp.S index ecd2bcd..0b0af03 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -103,7 +103,8 @@ GetObject: # called just after GetToken push %di # save 1 1: cmpsb jne 2f - cmp -1(%di),%al + dec %di + scasb jne 1b jmp 4f 2: pop %si # drop 1 @@ -112,9 +113,9 @@ GetObject: # called just after GetToken cmp (%di),%al jne 0b push %di # StpCpy -3: lodsb - stosb - test %al,%al +3: movsb + dec %di + scasb jnz 3b 4: pop %ax # restore 1 add $-g_str,%ax # stc From 50c85199fe56f58930d5c2d7fabfff3adc053d23 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 11:58:36 -0700 Subject: [PATCH 05/11] shave one more byte --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 14 +++++++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index b032869bc20c8ea63a09bd819158c06c3a1d211a..f95ed5beee8ddd321bf9f20018f7f56357ad88c5 100755 GIT binary patch delta 87 zcmV-d0I2_f1b_sPRT~Zg=vV--4d{#j>*&7#K#Bf{&^#b^0;-Ydc9C!v8*;yZKrp~p trga8Su66nA5njFkK(2NDIt6v>k)l}&W&b=W4}`n`=zfz00r>;YRjOipCMo~` delta 87 zcmV-d0I2_f1b_sPRT~ch=ve@;4d{&k>*&7#K#Bf{&^#b^0;-Ydcad-w9CN>bKrq0u t|5v7U22ZYa`Rfo~z5qb-t~v#E>XD&Y3S|F0DG!9a0O);_1OfR1RjPvbCW`<7 diff --git a/sectorlisp.S b/sectorlisp.S index 0b0af03..0f16fbc 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -99,25 +99,25 @@ GetObject: # called just after GetToken .Intern: mov $g_str,%di xor %al,%al -0: mov $-1,%cl - push %di # save 1 +0: push %di # save 1 1: cmpsb jne 2f dec %di scasb jne 1b - jmp 4f + jmp 5f 2: pop %si # drop 1 mov $g_token,%si - repne scasb +3: scasb + jne 3b cmp (%di),%al jne 0b push %di # StpCpy -3: movsb +4: movsb dec %di scasb - jnz 3b -4: pop %ax # restore 1 + jnz 4b +5: pop %ax # restore 1 add $-g_str,%ax # stc adc %ax,%ax # ax = 2 * ax + carry .ret: ret From 93d01e69328c2cc2ddd9cc435b79935fa73be5ab Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 12:23:43 -0700 Subject: [PATCH 06/11] shave one more byte --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 5 +++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index f95ed5beee8ddd321bf9f20018f7f56357ad88c5..62fc3e09c9fc997d0f244bdd9b6e28241692ebad 100755 GIT binary patch delta 112 zcmV-$0FVEG1b_sPRRIl=R;mHJlK}x1GD`qjUr^}m|CV2ujOVMCtCx)Dj^LNWgZ}|^ z7XNhut^YKOJ(lR=|6X5E=;{BKU+dVDN&zt+kN=ifr~!2zmy3M@SBpL9qW_X#>(PsJ S0*f>}J#>hZngL`3&Q+?&(>9y{ delta 112 zcmZo*X<(TU%E&h{Y!&04$&8F*#y$*D@c}R1{GS#-z32JrX{&)`--GFgoBuPGi2pBT z`d`A-ZQE_~;^F@|pt2W0Wv{PK_GC1a@B2S3Vg+NV-1P2Rrtogt7YqMSihq5v8>rmG P# Date: Fri, 5 Nov 2021 12:35:03 -0700 Subject: [PATCH 07/11] shave two more bytes --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 8 ++++---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 62fc3e09c9fc997d0f244bdd9b6e28241692ebad..0042cc3a59d3bf1ec53045ff467ad9843e50fcc6 100755 GIT binary patch delta 131 zcmZo*X<(TU%E&V@Y!&0K$&8F*j9!x^7>#|qYnj5kZM#{6UhptP#W(+8EP2~)`y!2D z1!HOU^lsMXAG|;nB~i^kBulObyqNHRS_Du=ZaPHUi^cyZ#lODTUBc9DVq;s)hHyKTE!gI)+QM8!A%VB~kHWh!~oZTljP zVFhDp#`JF1<{!M>K(VOiACe`P177t1pB4d>k(&+_1ZsV;=>Men*B84>n7U1DY)d*O i&tNncZ2raAd9CDGw~Qq_ziS9n>HEp|8D*J5R{;Q|q%;=* diff --git a/sectorlisp.S b/sectorlisp.S index 97a9252..6172800 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -228,6 +228,7 @@ Pairlis:cmp $NIL,%di # Pairlis(x:di,y:si,a:dx):ax 1: xchg %dx,%ax ret +1: mov 2(%di),%di # di = Cdr(c) Evcon: push %di # save c mov (%di),%di # di = Car(c) mov (%di),%ax # ax = Caar(c) @@ -236,8 +237,7 @@ Evcon: push %di # save c pop %dx # restore a pop %di # restore c cmp $NIL,%ax - cmove 2(%di),%di # di = Cdr(c) - jz Evcon + jz 1b mov (%di),%di # di = Car(c) .EvCadr:call Cadr # ax = Cadar(c) # jmp Eval @@ -300,13 +300,13 @@ Cadr: mov 2(%di),%di # contents of decrement register .retA: mov (%di),%ax # contents of address register ret +1: mov 2(%si),%dx # dx = Cdr(y) Assoc: cmp $NIL,%dx # Assoc(x:ax,y:dx):ax mov %dx,%si je .retF mov (%si),%bx # bx = Car(y) cmp %ax,(%bx) # (%bx) = Caar(y) - cmovne 2(%si),%dx # dx = Cdr(y) - jne Assoc + jne 1b mov 2(%bx),%ax # ax = Cdar(y) ret From ec2c93295fe4734160848ed82204540602224839 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 13:28:00 -0700 Subject: [PATCH 08/11] shave two more bytes --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 108 ++++++++++++++++++++++----------------------- 2 files changed, 54 insertions(+), 54 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 0042cc3a59d3bf1ec53045ff467ad9843e50fcc6..533f0fed9f8fd2da5417d74e8bd993d588479c60 100755 GIT binary patch delta 199 zcmV;&0671E1b_sPPYP=Qx&Z*_3IXUXky$Dh=w$$xr~#LB5Yg|AwSYjZgurx9=uwfx zA_XrzD0F#|hbLk&z|9sh+q4eN5IhZa@vsW(@`L{YbQb@00k-#Sw=sEzGr~#LB5Yg|AwSYjZ zgury`=q8bwB4q?Iz|9sh+q4eN5IhZaxUdTA^5|v%JSh)^x&Y{Y|4``g|LYWk{{eIy z|8)Y31yblr09s#A=bi!=;HrgUr^}j z|CV3t*pkDONdYb&kpGrgr~!2zmy3M@SBpL9qyLg$>(PsJ0*f>}J#>kamH}o0RjT{v BV6^}M diff --git a/sectorlisp.S b/sectorlisp.S index 6172800..d74ee14 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -93,35 +93,6 @@ GetToken: # GetToken():al, dl is g_look xchg %cx,%ax ret -GetObject: # called just after GetToken - cmpb $'(',%al - je GetList -.Intern: - mov $g_str,%di - xor %al,%al -0: push %di # save 1 -1: cmpsb - jne 2f - dec %di - scasb - jne 1b - jmp 5f -2: pop %si # drop 1 - mov $g_token,%si -3: scasb - jne 3b - cmp (%di),%al - jne 0b - push %di # StpCpy -4: movsb - dec %di - scasb - jnz 4b -5: pop %ax # restore 1 - add $-g_str,%ax # stc - adc %ax,%ax # ax = 2 * ax + carry -.ret: ret - .PutObject: # .PutObject(c:al,x:di) call PutChar # preserves di xchg %di,%ax @@ -157,6 +128,35 @@ PrintObject: # PrintObject(x:ax) 4: mov $')',%al jmp PutChar +GetObject: # called just after GetToken + cmpb $'(',%al + je GetList +.Intern: + mov $g_str,%di + xor %al,%al +0: push %di # save 1 +1: cmpsb + jne 2f + dec %di + scasb + jne 1b + jmp 5f +2: pop %si # drop 1 + mov $g_token,%si +3: scasb + jne 3b + cmp (%di),%al + jne 0b + push %di # StpCpy +4: movsb + dec %di + scasb + jnz 4b +5: pop %ax # restore 1 + add $-g_str,%ax # stc + adc %ax,%ax # ax = 2 * ax + carry +.ret: ret + GetChar: xor %ax,%ax # get keystroke int $0x16 # keyboard service @@ -175,16 +175,26 @@ PutChar: mov $'\n',%al jmp PutChar # bx volatile, bp never used -GetList:call GetToken - cmpb $')',%al - je .retF - call GetObject - push %ax # save 1 - call GetList - jmp xCons - //////////////////////////////////////////////////////////////////////////////// +Pairlis:cmp $NIL,%di # Pairlis(x:di,y:si,a:dx):ax + je 1f + push 2(%di) # save 1 Cdr(x) + lodsw + push (%si) # save 2 Cdr(y) + mov (%di),%di + xchg %ax,%si + call Cons # preserves dx + pop %si # restore 2 + pop %di # restore 1 + push %ax # save 3 + call Pairlis + xchg %ax,%si + pop %di # restore 3 + jmp Cons # can be inlined here +1: xchg %dx,%ax + ret + Evlis: cmp $NIL,%di # Evlis(m:di,a:dx):ax je 1f push 2(%di) # save 1 Cdr(m) @@ -210,23 +220,13 @@ Cons: xchg %di,%ax 1: xchg %di,%ax ret -Pairlis:cmp $NIL,%di # Pairlis(x:di,y:si,a:dx):ax - je 1f - push 2(%di) # save 1 Cdr(x) - lodsw - push (%si) # save 2 Cdr(y) - mov (%di),%di - xchg %ax,%si - call Cons # preserves dx - pop %si # restore 2 - pop %di # restore 1 - push %ax # save 3 - call Pairlis - xchg %ax,%si - pop %di # restore 3 - jmp Cons # can be inlined here -1: xchg %dx,%ax - ret +GetList:call GetToken + cmpb $')',%al + je .retF + call GetObject + push %ax # save 1 + call GetList + jmp xCons 1: mov 2(%di),%di # di = Cdr(c) Evcon: push %di # save c From a0f739da5815c86a121b51673110939431aa0a28 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 14:30:46 -0700 Subject: [PATCH 09/11] shave some bytes --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 22 ++++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 533f0fed9f8fd2da5417d74e8bd993d588479c60..60f04d1b22f372c9f0b9b68ca3477759acb8feea 100755 GIT binary patch delta 198 zcmV;%06G7F1b_sPDMxgG01gfg9|yhybcyj7iOl@C05*=`G5_*&7#c8UIo&^#b^0;-YdaglHoU0?v0r~#LB4$<$4{;Y(+ zbWG?@0PFU!DF1Z=i#_Py|5$_g0dx$g0hh2KbnCGB=*|DIDeEjeD0Fr)|1iK;rga8S zu66nA5njFkcCK~(It6v>SENs_b^BNWz(A4aR0t~nJSlW~=zNnx0lbs&0R;k8s)pQM Ay#N3J delta 199 zcmV;&0671E1b_sPDMxl-01gfg9|yhyc8T#9iOl>lz>eTC|MRN9fIzV&^Q5v0=o0|w zYXG_d0O$$<=q&)S4d{#j>*&7#K#Bf{&^#b^0;-Ydc9C!tVr2lAr~#LB5Yg|AwSYjZ zgurx9=urUc_OK}bbpne$=-vNVgZKe-45$H@upo5nu=(iA|F9|RFFYu8dB1=_Fu+%) zbp}tab@}TNUcLZ8u66x71$FCJq))DO`&b2lzY)NZ;Zz7E|2!#ldgytRJpsG|RjRu7 BUGD$@ diff --git a/sectorlisp.S b/sectorlisp.S index d74ee14..daf962b 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -30,8 +30,9 @@ .set ATOM_CONS, 61 .set ATOM_EQ, 71 -.set g_token, 0x4000 -.set g_str, 0x4080 +.set g_token, 0x7600 +.set g_str, 0x0 +.set g_mem, 0x3600 .set boot, 0x7c00 //////////////////////////////////////////////////////////////////////////////// @@ -45,8 +46,8 @@ kSymbols: .ascii "NIL\0T\0QUOTE\0COND\0ATOM\0CAR\0CDR\0CONS\0EQ" .type .init,@function -.init: ljmp $0x600>>4,$_begin # end of bios data roundup page -_begin: push %cs # memory model cs=ds=es = 0x600 +.init: ljmp $0x800>>4,$_begin # end of bios data roundup page +_begin: push %cs # memory model cs=ds=es = 0x800 push %cs push %cs pop %ds @@ -56,11 +57,11 @@ _begin: push %cs # memory model cs=ds=es = 0x600 pop %ss mov %cx,%sp cld - xor %ax,%ax + mov $g_mem,%ax mov %ax,%fs # fs = &g_mem xor %di,%di rep stosb # clears our bss memory -main: mov $g_str,%di +main: xor %di,%di # mov g_str, %di mov $37,%cl rep movsb 0: mov $'\n',%dl @@ -104,7 +105,7 @@ PrintObject: # PrintObject(x:ax) jz .PrintList .PrintAtom: shr %di - lea g_str(%di),%si + mov %di,%si # lea g_str(%di),%si .PrintString: # nul-terminated in si lodsb test %al,%al @@ -132,7 +133,7 @@ GetObject: # called just after GetToken cmpb $'(',%al je GetList .Intern: - mov $g_str,%di + xor %di,%di # mov $g_str,%di xor %al,%al 0: push %di # save 1 1: cmpsb @@ -153,8 +154,9 @@ GetObject: # called just after GetToken scasb jnz 4b 5: pop %ax # restore 1 - add $-g_str,%ax # stc - adc %ax,%ax # ax = 2 * ax + carry +# add $-g_str,%ax + add %ax,%ax # ax = 2 * ax + inc %ax # + 1 .ret: ret GetChar: From 0fb8fa3b2a55742ff63aa0535d70101f27be78cf Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 15:17:06 -0700 Subject: [PATCH 10/11] shave one more byte --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 16 ++++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 60f04d1b22f372c9f0b9b68ca3477759acb8feea..021a1873525712b0776efa803964608da6fdb899 100755 GIT binary patch delta 35 tcmV+;0Nnq81b_sPG!#}b|G6aq{PUz)7m3Wc05*=`^Qy5)wE+XpRjLeI5EcLc delta 35 tcmV+;0Nnq81b_sPG!=>Q7m3XLxBxbe;4%O6sxkkuCG(`QNVNe1RjMec5jp?> diff --git a/sectorlisp.S b/sectorlisp.S index daf962b..171dd5d 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -53,18 +53,18 @@ _begin: push %cs # memory model cs=ds=es = 0x800 pop %ds pop %es mov $kSymbols,%si - mov %si,%cx + push %si + xor %di,%di # mov g_str, %di + mov $37,%cx + cld + rep movsb + pop %cx pop %ss mov %cx,%sp - cld mov $g_mem,%ax mov %ax,%fs # fs = &g_mem - xor %di,%di rep stosb # clears our bss memory -main: xor %di,%di # mov g_str, %di - mov $37,%cl - rep movsb -0: mov $'\n',%dl +main: mov $'\n',%dl call GetToken call GetObject mov $NIL,%dx @@ -72,7 +72,7 @@ main: xor %di,%di # mov g_str, %di call PrintObject mov $'\r',%al call PutChar - jmp 0b + jmp main GetToken: # GetToken():al, dl is g_look mov $g_token,%di From 98e028d13b8c48635720518d9840324f3a416472 Mon Sep 17 00:00:00 2001 From: Peter Ferrie Date: Fri, 5 Nov 2021 15:21:25 -0700 Subject: [PATCH 11/11] restore load address, no need to change after all --- bin/sectorlisp.bin | Bin 512 -> 512 bytes sectorlisp.S | 6 +++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/sectorlisp.bin b/bin/sectorlisp.bin index 021a1873525712b0776efa803964608da6fdb899..cd664257a32b0f41ed4140a858990b36666995af 100755 GIT binary patch delta 32 ncmZo*X<(V4$z7Jfz{kfY&%TeTY@&%CW5vYeY{rU>=M5PFh%pHt delta 32 ncmZo*X<(V4$z9UGz{kfY&%TeTWTJ^4W7)*yY{s&U=M5PFio*#v diff --git a/sectorlisp.S b/sectorlisp.S index 171dd5d..693a76f 100644 --- a/sectorlisp.S +++ b/sectorlisp.S @@ -30,7 +30,7 @@ .set ATOM_CONS, 61 .set ATOM_EQ, 71 -.set g_token, 0x7600 +.set g_token, 0x7800 .set g_str, 0x0 .set g_mem, 0x3600 .set boot, 0x7c00 @@ -46,8 +46,8 @@ kSymbols: .ascii "NIL\0T\0QUOTE\0COND\0ATOM\0CAR\0CDR\0CONS\0EQ" .type .init,@function -.init: ljmp $0x800>>4,$_begin # end of bios data roundup page -_begin: push %cs # memory model cs=ds=es = 0x800 +.init: ljmp $0x600>>4,$_begin # end of bios data roundup page +_begin: push %cs # memory model cs=ds=es = 0x600 push %cs push %cs pop %ds