Giter Club home page Giter Club logo

sasm's People

Contributors

mras0 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sasm's Issues

Support for 'h' suffix.

A lot of my existing nasm code is using hex numbers in the format with the trailing 'h' (e.g. "0100h" instead of "0x100").

I don't know if this project is actively maintained, but it would be nice to have support for that alternate number format. I don't want to go through the whole forking process to be able to submit a pull request, but I did put together this little mod to add that in which seems to work fine as a potential starting place (I only bothered with SASM.COM, I'm sure doing this in the C version is fairly trivial):


diff --git a/sasm.asm b/sasm.asm
index 1e57006..9766700 100644
--- a/sasm.asm
+++ b/sasm.asm
@@ -833,11 +833,32 @@ Expect:

 ; Get number from Token to AX
 GetTokenNumber:
+               xor dl, dl                                      ; assume no "h" suffix
         cmp word [UToken], '0X'
         je .Hex
-        ; Decimal number
+
+               ; check if it has h suffix though (e.g. "0100h")
         xor ax, ax
         mov bx, UToken
+
+               mov al, [TokenLen]                      ; read length of token
+               add bx, ax                                      ; move past end of token
+               dec bx                                          ; back to point at last char
+               mov al, [bx]                            ; fetch last char of token
+
+               cmp al, 'H'                                     ; has "h" suffix?
+               jne .decimal                            ; if not, treat as decimal
+
+               ; hex number with 'h' suffix
+               inc dl                                          ; don't skip 2 chars for "0x" below
+        mov cl, [TokenLen]                     ; decrement len to process
+               dec cl                                          ; take off the 'h'
+               jmp short .Hex2
+
+.decimal:
+        ; Decimal number
+        mov bx, UToken
+               xor al, al
         xor ch, ch
 .Dec:
         mov cl, [bx]
@@ -858,11 +879,17 @@ GetTokenNumber:
 .Hex:
         mov cl, [TokenLen]
         sub cl, 2
+.Hex2:
         cmp cl, 4
         ja .Error
-        xor ax, ax
+
         mov bx, UToken
+               test dl, dl
+               jnz .noskip0x
         add bx, 2
+.noskip0x:
+
+        xor ax, ax
 .HexCvt:
         shl ax, 1
         shl ax, 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.